<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">交易日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="dt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">交易单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="jiaonum" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">交易金额</label>
                        <div class="layui-input-block">
                            <input type="text" name="money" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">交易类型</label>
                        <div class="layui-input-block">
                            <select id="modtype" name="modtype" lay-filter="modtype">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">款项摘要</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhai" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">交易对象</label>
                        <div class="layui-input-block">
                            <input type="text" name="duier" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">交易方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="incdaotype" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">账户名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="acc_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开户行</label>
                        <div class="layui-input-block">
                            <input type="text" name="acc_accname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">账户性质</label>
                        <div class="layui-input-block">
                            <div id="acctype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">账号</label>
                        <div class="layui-input-block">
                            <input type="text" name="acc_accnum" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">经办人</label>
                        <div class="layui-input-block">
                            <input type="text" name="baner" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('资金支出票款情况');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_account_list_zhipiao_list),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                var modtype_str = '<option value="">请选择</option>';
                var modtype = res.data.modtype;
                for (var key in modtype){
                    if(res.data.is_modtype == key){
                        modtype_str += '<option value="'+key+'" selected>'+modtype[key]+'</option>';
                    }else {
                        modtype_str += '<option value="'+key+'">'+modtype[key]+'</option>';
                    }

                }
                $("#modtype").html(modtype_str);

                xmselect_dan('acctype', res.data.acctype, res.data.is_acctype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                });

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'sericnum',title:'关联流程',templet: function(d){
                    return '<span class="colorlan" onclick="openPage(\'../'+d.modenum+'/show.php?id='+d.mid+'\');">'+d.sericnum+'</span>';
                }}
                ,{field:'statename',title:'票据状态',templet: function(d){
                    if(d.statename == '已收票'){
                        if(d.modtype == 11){
                            return '<span class="colorlv" onclick="openNavPage(\'工程付款信息\',\'hou_gongzhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 12){
                            return '<span class="colorlv" onclick="openNavPage(\'前期费支付信息\',\'qian_zhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 16){
                            return '<span class="colorlv" onclick="openNavPage(\'储备进项支付信息\',\'hou_chujin/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 19){
                            return '<span class="colorlv" onclick="openNavPage(\'日常付款信息\',\'hou_dayzhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }
                    }else if(d.statename == '部分收票'){
                        if(d.modtype == 11){
                            return '<span class="colorhuang" onclick="openNavPage(\'工程付款信息\',\'hou_gongzhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 12){
                            return '<span class="colorhuang" onclick="openNavPage(\'前期费支付信息\',\'qian_zhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 16){
                            return '<span class="colorhuang" onclick="openNavPage(\'储备进项支付信息\',\'hou_chujin/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 19){
                            return '<span class="colorhuang" onclick="openNavPage(\'日常付款信息\',\'hou_dayzhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }
                    }else if(d.statename == '未收票'){
                        if(d.modtype == 11){
                            return '<span class="colorhong" onclick="openNavPage(\'工程付款信息\',\'hou_gongzhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 12){
                            return '<span class="colorhong" onclick="openNavPage(\'前期费支付信息\',\'qian_zhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 16){
                            return '<span class="colorhong" onclick="openNavPage(\'储备进项支付信息\',\'hou_chujin/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }else if(d.modtype == 19){
                            return '<span class="colorhong" onclick="openNavPage(\'日常付款信息\',\'hou_dayzhi/detail.php?listid='+d.listid+'\');">'+d.statename+'</span>';
                        }
                    }else{
                        return d.statename;
                    }
                }}
                ,{field: 'enginname', title: '工程名称'}
                ,{field: 'jiaonum', title: '交易单号'}
                ,{field: 'modtype_name', title: '交易类型'}
                ,{field:'money',title:'交易金额(元)',totalRow: true,templet: function(d){return parseFormatNum(d.money);}}
                ,{field: 'kuanlei', title: '款项类型'}
                ,{field: 'zhai', title: '款项摘要'}
                ,{field: 'duier', title: '交易对象'}
                ,{field: 'incdaotype', title: '交易方式'}
                ,{field: 'dt', title: '交易日期'}
                // ,{field: 'accid_name', title: '资金账户'}
                ,{field: 'acc_name', title: '账户名称'}
                ,{field: 'acc_accname', title: '开户行'}
                ,{field: 'acc_acctype', title: '账户性质'}
                ,{field: 'acc_accnum', title: '账号'}
                ,{field: 'explain', title: '备注'}
                ,{field: 'baner', title: '经办人'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });


        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('../account_list/show.php?id='+trData.id);
    }



</script>
</body>
</html>
